import time

from Page.page_login import Login
from Tools.tools import DriverTools
from config import BASE_URL
from script import log


class TestLogin():
    def setup_method(self):
        driver = DriverTools.get_driver()
        driver.get(BASE_URL+"/common/member/login")
        self.login = Login(driver)

    def teardown_method(self):
        DriverTools.close_driver()



    def test_login_success_all(self):
        self.login.login_succeses('18738142070', "test123456")
        time.sleep(2)
        result2 = self.login.assert_login()
        log.info(f"执行结果{result2}")
        assert '18738142070' in result2
        self.login.get_shot("login_success.png")

    def test_login_fail_not_reg(self):
        self.login.login_succeses("17801004889", "test123456")
        time.sleep(1)
        result2 = self.login.assert_login_fail()
        log.info(f"执行结果{result2}")
        assert "用户登录" in result2
        self.login.get_shot("login_fail_not_reg.png")

    def test_login_fail_password(self):
        self.login.login_succeses("17800004889", "test1234567")
        time.sleep(1)
        result2 = self.login.assert_login_fail_pwd()
        log.info(f"执行结果{result2}")
        assert "密码错误" in result2
